import { View, WebView } from '@tarojs/components'
import React,{ useState } from 'react'
import {getToken} from '@/utils/index';
import Taro,{ useDidShow } from '@tarojs/taro'

export default function WebDiv() {
  const [url,setUrl] = useState('')
  useDidShow(()=>{
    const {router} = Taro.getCurrentInstance()
    const params = router.params
    let url = decodeURIComponent(params.url)
    if(getToken()){
      url = url + `${url.includes('?')?'&':'?'}token=${getToken()}&channel=${Taro.$channel}&t=${Date.now()}`
    }
    console.log(url,'url-------')
    setUrl(url)
  })

  return (
    <View className='web-div'>
      <WebView src={url}></WebView>
    </View>
  )
}
